Fix path separator error only showing for existing directories#1939
Conversation
Previously, fd would only warn about path separators in the search
pattern when the pattern happened to be an existing directory. Patterns
like 'nonexistent/path' would silently return no results with no
indication of what went wrong.
Now the error fires whenever the pattern contains a path separator,
regardless of whether it exists on disk. The directory-specific hint
('use fd . <dir>') only shows when the path actually is a directory.
Fixes #1873
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1873.
The path separator check in
ensure_search_pattern_is_not_a_pathonly fired when the pattern was an existing directory (because of the.is_dir()gate). Sofd /would error, butfd nonexistent/pathwould silently return nothing with no hint about what went wrong.This removes the
.is_dir()requirement so the error shows whenever the pattern contains a path separator. The "search inside this directory" hint still only shows when the path actually exists as a directory, since that suggestion only makes sense in that case.Changes
src/main.rs: Remove.is_dir()gate, conditionally include directory hinttests/tests.rs: Add test covering both existing and non-existing directory patternsTest plan
1 new test, all existing tests still pass.